namespace Beauty.Net.RabbitMQ.SimpleQueue
{
    /// <summary>
    /// 简单队列消费者
    /// </summary>
    public class SimpleQueueConsumer<T> : RabbitMQConsumerBase<T>
    {
        public SimpleQueueConsumer(IRabbitMQConnectionManager connectionManager,
                                 string queueName,
                                 MessageHandler<T> messageHandler,
                                 bool autoAck = false)
            : base(connectionManager, string.Empty, queueName, queueName, messageHandler, autoAck)
        {}

        protected override void SetupExchangeAndQueue()
        {
            if (_channel == null) throw new InvalidOperationException("Channel not initialized");
            
            // 声明队列
            _channel.QueueDeclare(queue: QueueName,
                                 durable: true,
                                 exclusive: false,
                                 autoDelete: false,
                                 arguments: null);
        }
    }
}